<?php


/**
 * Base class that represents a query for the 'calendar_events' table.
 *
 *
 *
 * @method RcpCalendarEventsQuery orderById($order = Criteria::ASC) Order by the id column
 * @method RcpCalendarEventsQuery orderByUserId($order = Criteria::ASC) Order by the user_id column
 * @method RcpCalendarEventsQuery orderByEventDefId($order = Criteria::ASC) Order by the event_def_id column
 * @method RcpCalendarEventsQuery orderByDate($order = Criteria::ASC) Order by the date column
 * @method RcpCalendarEventsQuery orderByStartDate($order = Criteria::ASC) Order by the start_date column
 * @method RcpCalendarEventsQuery orderByEndDate($order = Criteria::ASC) Order by the end_date column
 * @method RcpCalendarEventsQuery orderByStartExtId($order = Criteria::ASC) Order by the start_ext_id column
 * @method RcpCalendarEventsQuery orderByEndExtId($order = Criteria::ASC) Order by the end_ext_id column
 * @method RcpCalendarEventsQuery orderByExtraTime($order = Criteria::ASC) Order by the extra_time column
 * @method RcpCalendarEventsQuery orderByCanceled($order = Criteria::ASC) Order by the canceled column
 * @method RcpCalendarEventsQuery orderByActive($order = Criteria::ASC) Order by the active column
 * @method RcpCalendarEventsQuery orderByLastModified($order = Criteria::ASC) Order by the last_modified column
 * @method RcpCalendarEventsQuery orderByCreated($order = Criteria::ASC) Order by the created column
 *
 * @method RcpCalendarEventsQuery groupById() Group by the id column
 * @method RcpCalendarEventsQuery groupByUserId() Group by the user_id column
 * @method RcpCalendarEventsQuery groupByEventDefId() Group by the event_def_id column
 * @method RcpCalendarEventsQuery groupByDate() Group by the date column
 * @method RcpCalendarEventsQuery groupByStartDate() Group by the start_date column
 * @method RcpCalendarEventsQuery groupByEndDate() Group by the end_date column
 * @method RcpCalendarEventsQuery groupByStartExtId() Group by the start_ext_id column
 * @method RcpCalendarEventsQuery groupByEndExtId() Group by the end_ext_id column
 * @method RcpCalendarEventsQuery groupByExtraTime() Group by the extra_time column
 * @method RcpCalendarEventsQuery groupByCanceled() Group by the canceled column
 * @method RcpCalendarEventsQuery groupByActive() Group by the active column
 * @method RcpCalendarEventsQuery groupByLastModified() Group by the last_modified column
 * @method RcpCalendarEventsQuery groupByCreated() Group by the created column
 *
 * @method RcpCalendarEventsQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
 * @method RcpCalendarEventsQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
 * @method RcpCalendarEventsQuery innerJoin($relation) Adds a INNER JOIN clause to the query
 *
 * @method RcpCalendarEventsQuery leftJoinEventDefs($relationAlias = null) Adds a LEFT JOIN clause to the query using the EventDefs relation
 * @method RcpCalendarEventsQuery rightJoinEventDefs($relationAlias = null) Adds a RIGHT JOIN clause to the query using the EventDefs relation
 * @method RcpCalendarEventsQuery innerJoinEventDefs($relationAlias = null) Adds a INNER JOIN clause to the query using the EventDefs relation
 *
 * @method RcpCalendarEventsQuery leftJoinUsers($relationAlias = null) Adds a LEFT JOIN clause to the query using the Users relation
 * @method RcpCalendarEventsQuery rightJoinUsers($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Users relation
 * @method RcpCalendarEventsQuery innerJoinUsers($relationAlias = null) Adds a INNER JOIN clause to the query using the Users relation
 *
 * @method RcpCalendarEventsQuery leftJoinEventRequestHasCalendarEvent($relationAlias = null) Adds a LEFT JOIN clause to the query using the EventRequestHasCalendarEvent relation
 * @method RcpCalendarEventsQuery rightJoinEventRequestHasCalendarEvent($relationAlias = null) Adds a RIGHT JOIN clause to the query using the EventRequestHasCalendarEvent relation
 * @method RcpCalendarEventsQuery innerJoinEventRequestHasCalendarEvent($relationAlias = null) Adds a INNER JOIN clause to the query using the EventRequestHasCalendarEvent relation
 *
 * @method RcpCalendarEvents findOne(PropelPDO $con = null) Return the first RcpCalendarEvents matching the query
 * @method RcpCalendarEvents findOneOrCreate(PropelPDO $con = null) Return the first RcpCalendarEvents matching the query, or a new RcpCalendarEvents object populated from the query conditions when no match is found
 *
 * @method RcpCalendarEvents findOneById(int $id) Return the first RcpCalendarEvents filtered by the id column
 * @method RcpCalendarEvents findOneByUserId(int $user_id) Return the first RcpCalendarEvents filtered by the user_id column
 * @method RcpCalendarEvents findOneByEventDefId(int $event_def_id) Return the first RcpCalendarEvents filtered by the event_def_id column
 * @method RcpCalendarEvents findOneByDate(string $date) Return the first RcpCalendarEvents filtered by the date column
 * @method RcpCalendarEvents findOneByStartDate(string $start_date) Return the first RcpCalendarEvents filtered by the start_date column
 * @method RcpCalendarEvents findOneByEndDate(string $end_date) Return the first RcpCalendarEvents filtered by the end_date column
 * @method RcpCalendarEvents findOneByStartExtId(string $start_ext_id) Return the first RcpCalendarEvents filtered by the start_ext_id column
 * @method RcpCalendarEvents findOneByEndExtId(string $end_ext_id) Return the first RcpCalendarEvents filtered by the end_ext_id column
 * @method RcpCalendarEvents findOneByExtraTime(int $extra_time) Return the first RcpCalendarEvents filtered by the extra_time column
 * @method RcpCalendarEvents findOneByCanceled(string $canceled) Return the first RcpCalendarEvents filtered by the canceled column
 * @method RcpCalendarEvents findOneByActive(boolean $active) Return the first RcpCalendarEvents filtered by the active column
 * @method RcpCalendarEvents findOneByLastModified(string $last_modified) Return the first RcpCalendarEvents filtered by the last_modified column
 * @method RcpCalendarEvents findOneByCreated(string $created) Return the first RcpCalendarEvents filtered by the created column
 *
 * @method array findById(int $id) Return RcpCalendarEvents objects filtered by the id column
 * @method array findByUserId(int $user_id) Return RcpCalendarEvents objects filtered by the user_id column
 * @method array findByEventDefId(int $event_def_id) Return RcpCalendarEvents objects filtered by the event_def_id column
 * @method array findByDate(string $date) Return RcpCalendarEvents objects filtered by the date column
 * @method array findByStartDate(string $start_date) Return RcpCalendarEvents objects filtered by the start_date column
 * @method array findByEndDate(string $end_date) Return RcpCalendarEvents objects filtered by the end_date column
 * @method array findByStartExtId(string $start_ext_id) Return RcpCalendarEvents objects filtered by the start_ext_id column
 * @method array findByEndExtId(string $end_ext_id) Return RcpCalendarEvents objects filtered by the end_ext_id column
 * @method array findByExtraTime(int $extra_time) Return RcpCalendarEvents objects filtered by the extra_time column
 * @method array findByCanceled(string $canceled) Return RcpCalendarEvents objects filtered by the canceled column
 * @method array findByActive(boolean $active) Return RcpCalendarEvents objects filtered by the active column
 * @method array findByLastModified(string $last_modified) Return RcpCalendarEvents objects filtered by the last_modified column
 * @method array findByCreated(string $created) Return RcpCalendarEvents objects filtered by the created column
 *
 * @package    propel.generator.rcp.om
 */
abstract class RcpBaseCalendarEventsQuery extends ModelCriteria
{
    /**
     * Initializes internal state of RcpBaseCalendarEventsQuery object.
     *
     * @param     string $dbName The dabase name
     * @param     string $modelName The phpName of a model, e.g. 'Book'
     * @param     string $modelAlias The alias for the model in this query, e.g. 'b'
     */
    public function __construct($dbName = 'vgp_rcp', $modelName = 'RcpCalendarEvents', $modelAlias = null)
    {
        parent::__construct($dbName, $modelName, $modelAlias);
    }

    /**
     * Returns a new RcpCalendarEventsQuery object.
     *
     * @param     string $modelAlias The alias of a model in the query
     * @param     RcpCalendarEventsQuery|Criteria $criteria Optional Criteria to build the query from
     *
     * @return RcpCalendarEventsQuery
     */
    public static function create($modelAlias = null, $criteria = null)
    {
        if ($criteria instanceof RcpCalendarEventsQuery) {
            return $criteria;
        }
        $query = new RcpCalendarEventsQuery();
        if (null !== $modelAlias) {
            $query->setModelAlias($modelAlias);
        }
        if ($criteria instanceof Criteria) {
            $query->mergeWith($criteria);
        }

        return $query;
    }

    /**
     * Find object by primary key.
     * Propel uses the instance pool to skip the database if the object exists.
     * Go fast if the query is untouched.
     *
     * <code>
     * $obj  = $c->findPk(12, $con);
     * </code>
     *
     * @param mixed $key Primary key to use for the query
     * @param     PropelPDO $con an optional connection object
     *
     * @return   RcpCalendarEvents|RcpCalendarEvents[]|mixed the result, formatted by the current formatter
     */
    public function findPk($key, $con = null)
    {
        if ($key === null) {
            return null;
        }
        if ((null !== ($obj = RcpCalendarEventsPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
            // the object is alredy in the instance pool
            return $obj;
        }
        if ($con === null) {
            $con = Propel::getConnection(RcpCalendarEventsPeer::DATABASE_NAME, Propel::CONNECTION_READ);
        }
        $this->basePreSelect($con);
        if ($this->formatter || $this->modelAlias || $this->with || $this->select
         || $this->selectColumns || $this->asColumns || $this->selectModifiers
         || $this->map || $this->having || $this->joins) {
            return $this->findPkComplex($key, $con);
        } else {
            return $this->findPkSimple($key, $con);
        }
    }

    /**
     * Find object by primary key using raw SQL to go fast.
     * Bypass doSelect() and the object formatter by using generated code.
     *
     * @param     mixed $key Primary key to use for the query
     * @param     PropelPDO $con A connection object
     *
     * @return   RcpCalendarEvents A model object, or null if the key is not found
     * @throws   PropelException
     */
    protected function findPkSimple($key, $con)
    {
        $sql = 'SELECT ID, USER_ID, EVENT_DEF_ID, DATE, START_DATE, END_DATE, START_EXT_ID, END_EXT_ID, EXTRA_TIME, CANCELED, ACTIVE, LAST_MODIFIED, CREATED FROM calendar_events WHERE ID = :p0';
        try {
            $stmt = $con->prepare($sql);
            $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
            $stmt->execute();
        } catch (Exception $e) {
            Propel::log($e->getMessage(), Propel::LOG_ERR);
            throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
        }
        $obj = null;
        if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
            $obj = new RcpCalendarEvents();
            $obj->hydrate($row);
            RcpCalendarEventsPeer::addInstanceToPool($obj, (string) $key);
        }
        $stmt->closeCursor();

        return $obj;
    }

    /**
     * Find object by primary key.
     *
     * @param     mixed $key Primary key to use for the query
     * @param     PropelPDO $con A connection object
     *
     * @return RcpCalendarEvents|RcpCalendarEvents[]|mixed the result, formatted by the current formatter
     */
    protected function findPkComplex($key, $con)
    {
        // As the query uses a PK condition, no limit(1) is necessary.
        $criteria = $this->isKeepQuery() ? clone $this : $this;
        $stmt = $criteria
            ->filterByPrimaryKey($key)
            ->doSelect($con);

        return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
    }

    /**
     * Find objects by primary key
     * <code>
     * $objs = $c->findPks(array(12, 56, 832), $con);
     * </code>
     * @param     array $keys Primary keys to use for the query
     * @param     PropelPDO $con an optional connection object
     *
     * @return PropelObjectCollection|RcpCalendarEvents[]|mixed the list of results, formatted by the current formatter
     */
    public function findPks($keys, $con = null)
    {
        if ($con === null) {
            $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
        }
        $this->basePreSelect($con);
        $criteria = $this->isKeepQuery() ? clone $this : $this;
        $stmt = $criteria
            ->filterByPrimaryKeys($keys)
            ->doSelect($con);

        return $criteria->getFormatter()->init($criteria)->format($stmt);
    }

    /**
     * Filter the query by primary key
     *
     * @param     mixed $key Primary key to use for the query
     *
     * @return RcpCalendarEventsQuery The current query, for fluid interface
     */
    public function filterByPrimaryKey($key)
    {

        return $this->addUsingAlias(RcpCalendarEventsPeer::ID, $key, Criteria::EQUAL);
    }

    /**
     * Filter the query by a list of primary keys
     *
     * @param     array $keys The list of primary key to use for the query
     *
     * @return RcpCalendarEventsQuery The current query, for fluid interface
     */
    public function filterByPrimaryKeys($keys)
    {

        return $this->addUsingAlias(RcpCalendarEventsPeer::ID, $keys, Criteria::IN);
    }

    /**
     * Filter the query on the id column
     *
     * Example usage:
     * <code>
     * $query->filterById(1234); // WHERE id = 1234
     * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
     * $query->filterById(array('min' => 12)); // WHERE id > 12
     * </code>
     *
     * @param     mixed $id The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return RcpCalendarEventsQuery The current query, for fluid interface
     */
    public function filterById($id = null, $comparison = null)
    {
        if (is_array($id) && null === $comparison) {
            $comparison = Criteria::IN;
        }

        return $this->addUsingAlias(RcpCalendarEventsPeer::ID, $id, $comparison);
    }

    /**
     * Filter the query on the user_id column
     *
     * Example usage:
     * <code>
     * $query->filterByUserId(1234); // WHERE user_id = 1234
     * $query->filterByUserId(array(12, 34)); // WHERE user_id IN (12, 34)
     * $query->filterByUserId(array('min' => 12)); // WHERE user_id > 12
     * </code>
     *
     * @see       filterByUsers()
     *
     * @param     mixed $userId The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return RcpCalendarEventsQuery The current query, for fluid interface
     */
    public function filterByUserId($userId = null, $comparison = null)
    {
        if (is_array($userId)) {
            $useMinMax = false;
            if (isset($userId['min'])) {
                $this->addUsingAlias(RcpCalendarEventsPeer::USER_ID, $userId['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($userId['max'])) {
                $this->addUsingAlias(RcpCalendarEventsPeer::USER_ID, $userId['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(RcpCalendarEventsPeer::USER_ID, $userId, $comparison);
    }

    /**
     * Filter the query on the event_def_id column
     *
     * Example usage:
     * <code>
     * $query->filterByEventDefId(1234); // WHERE event_def_id = 1234
     * $query->filterByEventDefId(array(12, 34)); // WHERE event_def_id IN (12, 34)
     * $query->filterByEventDefId(array('min' => 12)); // WHERE event_def_id > 12
     * </code>
     *
     * @see       filterByEventDefs()
     *
     * @param     mixed $eventDefId The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return RcpCalendarEventsQuery The current query, for fluid interface
     */
    public function filterByEventDefId($eventDefId = null, $comparison = null)
    {
        if (is_array($eventDefId)) {
            $useMinMax = false;
            if (isset($eventDefId['min'])) {
                $this->addUsingAlias(RcpCalendarEventsPeer::EVENT_DEF_ID, $eventDefId['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($eventDefId['max'])) {
                $this->addUsingAlias(RcpCalendarEventsPeer::EVENT_DEF_ID, $eventDefId['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(RcpCalendarEventsPeer::EVENT_DEF_ID, $eventDefId, $comparison);
    }

    /**
     * Filter the query on the date column
     *
     * Example usage:
     * <code>
     * $query->filterByDate('fooValue');   // WHERE date = 'fooValue'
     * $query->filterByDate('%fooValue%'); // WHERE date LIKE '%fooValue%'
     * </code>
     *
     * @param     string $date The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return RcpCalendarEventsQuery The current query, for fluid interface
     */
    public function filterByDate($date = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($date)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $date)) {
                $date = str_replace('*', '%', $date);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(RcpCalendarEventsPeer::DATE, $date, $comparison);
    }

    /**
     * Filter the query on the start_date column
     *
     * Example usage:
     * <code>
     * $query->filterByStartDate('2011-03-14'); // WHERE start_date = '2011-03-14'
     * $query->filterByStartDate('now'); // WHERE start_date = '2011-03-14'
     * $query->filterByStartDate(array('max' => 'yesterday')); // WHERE start_date > '2011-03-13'
     * </code>
     *
     * @param     mixed $startDate The value to use as filter.
     *              Values can be integers (unix timestamps), DateTime objects, or strings.
     *              Empty strings are treated as NULL.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return RcpCalendarEventsQuery The current query, for fluid interface
     */
    public function filterByStartDate($startDate = null, $comparison = null)
    {
        if (is_array($startDate)) {
            $useMinMax = false;
            if (isset($startDate['min'])) {
                $this->addUsingAlias(RcpCalendarEventsPeer::START_DATE, $startDate['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($startDate['max'])) {
                $this->addUsingAlias(RcpCalendarEventsPeer::START_DATE, $startDate['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(RcpCalendarEventsPeer::START_DATE, $startDate, $comparison);
    }

    /**
     * Filter the query on the end_date column
     *
     * Example usage:
     * <code>
     * $query->filterByEndDate('2011-03-14'); // WHERE end_date = '2011-03-14'
     * $query->filterByEndDate('now'); // WHERE end_date = '2011-03-14'
     * $query->filterByEndDate(array('max' => 'yesterday')); // WHERE end_date > '2011-03-13'
     * </code>
     *
     * @param     mixed $endDate The value to use as filter.
     *              Values can be integers (unix timestamps), DateTime objects, or strings.
     *              Empty strings are treated as NULL.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return RcpCalendarEventsQuery The current query, for fluid interface
     */
    public function filterByEndDate($endDate = null, $comparison = null)
    {
        if (is_array($endDate)) {
            $useMinMax = false;
            if (isset($endDate['min'])) {
                $this->addUsingAlias(RcpCalendarEventsPeer::END_DATE, $endDate['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($endDate['max'])) {
                $this->addUsingAlias(RcpCalendarEventsPeer::END_DATE, $endDate['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(RcpCalendarEventsPeer::END_DATE, $endDate, $comparison);
    }

    /**
     * Filter the query on the start_ext_id column
     *
     * Example usage:
     * <code>
     * $query->filterByStartExtId(1234); // WHERE start_ext_id = 1234
     * $query->filterByStartExtId(array(12, 34)); // WHERE start_ext_id IN (12, 34)
     * $query->filterByStartExtId(array('min' => 12)); // WHERE start_ext_id > 12
     * </code>
     *
     * @param     mixed $startExtId The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return RcpCalendarEventsQuery The current query, for fluid interface
     */
    public function filterByStartExtId($startExtId = null, $comparison = null)
    {
        if (is_array($startExtId)) {
            $useMinMax = false;
            if (isset($startExtId['min'])) {
                $this->addUsingAlias(RcpCalendarEventsPeer::START_EXT_ID, $startExtId['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($startExtId['max'])) {
                $this->addUsingAlias(RcpCalendarEventsPeer::START_EXT_ID, $startExtId['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(RcpCalendarEventsPeer::START_EXT_ID, $startExtId, $comparison);
    }

    /**
     * Filter the query on the end_ext_id column
     *
     * Example usage:
     * <code>
     * $query->filterByEndExtId(1234); // WHERE end_ext_id = 1234
     * $query->filterByEndExtId(array(12, 34)); // WHERE end_ext_id IN (12, 34)
     * $query->filterByEndExtId(array('min' => 12)); // WHERE end_ext_id > 12
     * </code>
     *
     * @param     mixed $endExtId The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return RcpCalendarEventsQuery The current query, for fluid interface
     */
    public function filterByEndExtId($endExtId = null, $comparison = null)
    {
        if (is_array($endExtId)) {
            $useMinMax = false;
            if (isset($endExtId['min'])) {
                $this->addUsingAlias(RcpCalendarEventsPeer::END_EXT_ID, $endExtId['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($endExtId['max'])) {
                $this->addUsingAlias(RcpCalendarEventsPeer::END_EXT_ID, $endExtId['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(RcpCalendarEventsPeer::END_EXT_ID, $endExtId, $comparison);
    }

    /**
     * Filter the query on the extra_time column
     *
     * Example usage:
     * <code>
     * $query->filterByExtraTime(1234); // WHERE extra_time = 1234
     * $query->filterByExtraTime(array(12, 34)); // WHERE extra_time IN (12, 34)
     * $query->filterByExtraTime(array('min' => 12)); // WHERE extra_time > 12
     * </code>
     *
     * @param     mixed $extraTime The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return RcpCalendarEventsQuery The current query, for fluid interface
     */
    public function filterByExtraTime($extraTime = null, $comparison = null)
    {
        if (is_array($extraTime)) {
            $useMinMax = false;
            if (isset($extraTime['min'])) {
                $this->addUsingAlias(RcpCalendarEventsPeer::EXTRA_TIME, $extraTime['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($extraTime['max'])) {
                $this->addUsingAlias(RcpCalendarEventsPeer::EXTRA_TIME, $extraTime['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(RcpCalendarEventsPeer::EXTRA_TIME, $extraTime, $comparison);
    }

    /**
     * Filter the query on the canceled column
     *
     * Example usage:
     * <code>
     * $query->filterByCanceled('2011-03-14'); // WHERE canceled = '2011-03-14'
     * $query->filterByCanceled('now'); // WHERE canceled = '2011-03-14'
     * $query->filterByCanceled(array('max' => 'yesterday')); // WHERE canceled > '2011-03-13'
     * </code>
     *
     * @param     mixed $canceled The value to use as filter.
     *              Values can be integers (unix timestamps), DateTime objects, or strings.
     *              Empty strings are treated as NULL.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return RcpCalendarEventsQuery The current query, for fluid interface
     */
    public function filterByCanceled($canceled = null, $comparison = null)
    {
        if (is_array($canceled)) {
            $useMinMax = false;
            if (isset($canceled['min'])) {
                $this->addUsingAlias(RcpCalendarEventsPeer::CANCELED, $canceled['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($canceled['max'])) {
                $this->addUsingAlias(RcpCalendarEventsPeer::CANCELED, $canceled['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(RcpCalendarEventsPeer::CANCELED, $canceled, $comparison);
    }

    /**
     * Filter the query on the active column
     *
     * Example usage:
     * <code>
     * $query->filterByActive(true); // WHERE active = true
     * $query->filterByActive('yes'); // WHERE active = true
     * </code>
     *
     * @param     boolean|string $active The value to use as filter.
     *              Non-boolean arguments are converted using the following rules:
     *                * 1, '1', 'true',  'on',  and 'yes' are converted to boolean true
     *                * 0, '0', 'false', 'off', and 'no'  are converted to boolean false
     *              Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return RcpCalendarEventsQuery The current query, for fluid interface
     */
    public function filterByActive($active = null, $comparison = null)
    {
        if (is_string($active)) {
            $active = in_array(strtolower($active), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
        }

        return $this->addUsingAlias(RcpCalendarEventsPeer::ACTIVE, $active, $comparison);
    }

    /**
     * Filter the query on the last_modified column
     *
     * Example usage:
     * <code>
     * $query->filterByLastModified('2011-03-14'); // WHERE last_modified = '2011-03-14'
     * $query->filterByLastModified('now'); // WHERE last_modified = '2011-03-14'
     * $query->filterByLastModified(array('max' => 'yesterday')); // WHERE last_modified > '2011-03-13'
     * </code>
     *
     * @param     mixed $lastModified The value to use as filter.
     *              Values can be integers (unix timestamps), DateTime objects, or strings.
     *              Empty strings are treated as NULL.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return RcpCalendarEventsQuery The current query, for fluid interface
     */
    public function filterByLastModified($lastModified = null, $comparison = null)
    {
        if (is_array($lastModified)) {
            $useMinMax = false;
            if (isset($lastModified['min'])) {
                $this->addUsingAlias(RcpCalendarEventsPeer::LAST_MODIFIED, $lastModified['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($lastModified['max'])) {
                $this->addUsingAlias(RcpCalendarEventsPeer::LAST_MODIFIED, $lastModified['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(RcpCalendarEventsPeer::LAST_MODIFIED, $lastModified, $comparison);
    }

    /**
     * Filter the query on the created column
     *
     * Example usage:
     * <code>
     * $query->filterByCreated('2011-03-14'); // WHERE created = '2011-03-14'
     * $query->filterByCreated('now'); // WHERE created = '2011-03-14'
     * $query->filterByCreated(array('max' => 'yesterday')); // WHERE created > '2011-03-13'
     * </code>
     *
     * @param     mixed $created The value to use as filter.
     *              Values can be integers (unix timestamps), DateTime objects, or strings.
     *              Empty strings are treated as NULL.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return RcpCalendarEventsQuery The current query, for fluid interface
     */
    public function filterByCreated($created = null, $comparison = null)
    {
        if (is_array($created)) {
            $useMinMax = false;
            if (isset($created['min'])) {
                $this->addUsingAlias(RcpCalendarEventsPeer::CREATED, $created['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($created['max'])) {
                $this->addUsingAlias(RcpCalendarEventsPeer::CREATED, $created['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(RcpCalendarEventsPeer::CREATED, $created, $comparison);
    }

    /**
     * Filter the query by a related RcpEventDefs object
     *
     * @param   RcpEventDefs|PropelObjectCollection $eventDefs The related object(s) to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   RcpCalendarEventsQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByEventDefs($eventDefs, $comparison = null)
    {
        if ($eventDefs instanceof RcpEventDefs) {
            return $this
                ->addUsingAlias(RcpCalendarEventsPeer::EVENT_DEF_ID, $eventDefs->getId(), $comparison);
        } elseif ($eventDefs instanceof PropelObjectCollection) {
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }

            return $this
                ->addUsingAlias(RcpCalendarEventsPeer::EVENT_DEF_ID, $eventDefs->toKeyValue('PrimaryKey', 'Id'), $comparison);
        } else {
            throw new PropelException('filterByEventDefs() only accepts arguments of type RcpEventDefs or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the EventDefs relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return RcpCalendarEventsQuery The current query, for fluid interface
     */
    public function joinEventDefs($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('EventDefs');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'EventDefs');
        }

        return $this;
    }

    /**
     * Use the EventDefs relation EventDefs object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   RcpEventDefsQuery A secondary query class using the current class as primary query
     */
    public function useEventDefsQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        return $this
            ->joinEventDefs($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'EventDefs', 'RcpEventDefsQuery');
    }

    /**
     * Filter the query by a related RcpUsers object
     *
     * @param   RcpUsers|PropelObjectCollection $users The related object(s) to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   RcpCalendarEventsQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByUsers($users, $comparison = null)
    {
        if ($users instanceof RcpUsers) {
            return $this
                ->addUsingAlias(RcpCalendarEventsPeer::USER_ID, $users->getId(), $comparison);
        } elseif ($users instanceof PropelObjectCollection) {
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }

            return $this
                ->addUsingAlias(RcpCalendarEventsPeer::USER_ID, $users->toKeyValue('PrimaryKey', 'Id'), $comparison);
        } else {
            throw new PropelException('filterByUsers() only accepts arguments of type RcpUsers or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the Users relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return RcpCalendarEventsQuery The current query, for fluid interface
     */
    public function joinUsers($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('Users');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'Users');
        }

        return $this;
    }

    /**
     * Use the Users relation Users object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   RcpUsersQuery A secondary query class using the current class as primary query
     */
    public function useUsersQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        return $this
            ->joinUsers($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'Users', 'RcpUsersQuery');
    }

    /**
     * Filter the query by a related RcpEventRequestHasCalendarEvent object
     *
     * @param   RcpEventRequestHasCalendarEvent|PropelObjectCollection $eventRequestHasCalendarEvent  the related object to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   RcpCalendarEventsQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByEventRequestHasCalendarEvent($eventRequestHasCalendarEvent, $comparison = null)
    {
        if ($eventRequestHasCalendarEvent instanceof RcpEventRequestHasCalendarEvent) {
            return $this
                ->addUsingAlias(RcpCalendarEventsPeer::ID, $eventRequestHasCalendarEvent->getCalendarEventId(), $comparison);
        } elseif ($eventRequestHasCalendarEvent instanceof PropelObjectCollection) {
            return $this
                ->useEventRequestHasCalendarEventQuery()
                ->filterByPrimaryKeys($eventRequestHasCalendarEvent->getPrimaryKeys())
                ->endUse();
        } else {
            throw new PropelException('filterByEventRequestHasCalendarEvent() only accepts arguments of type RcpEventRequestHasCalendarEvent or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the EventRequestHasCalendarEvent relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return RcpCalendarEventsQuery The current query, for fluid interface
     */
    public function joinEventRequestHasCalendarEvent($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('EventRequestHasCalendarEvent');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'EventRequestHasCalendarEvent');
        }

        return $this;
    }

    /**
     * Use the EventRequestHasCalendarEvent relation EventRequestHasCalendarEvent object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   RcpEventRequestHasCalendarEventQuery A secondary query class using the current class as primary query
     */
    public function useEventRequestHasCalendarEventQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        return $this
            ->joinEventRequestHasCalendarEvent($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'EventRequestHasCalendarEvent', 'RcpEventRequestHasCalendarEventQuery');
    }

    /**
     * Exclude object from result
     *
     * @param   RcpCalendarEvents $calendarEvents Object to remove from the list of results
     *
     * @return RcpCalendarEventsQuery The current query, for fluid interface
     */
    public function prune($calendarEvents = null)
    {
        if ($calendarEvents) {
            $this->addUsingAlias(RcpCalendarEventsPeer::ID, $calendarEvents->getId(), Criteria::NOT_EQUAL);
        }

        return $this;
    }

}
